[rb] External Control of File Name or Path use of Kernel.open or IO.read with a non-constant value
#16086
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
selenium/rake_tasks/crazy_fun/main.rb
Line 150 in 3744929
fix address the issue replace the usage of
IO.readwithFile.read. This change ensures that the file-reading operation does not inadvertently execute shell commands if the file name starts with a|. The functionality remains the same, asFile.readis a direct and safer alternative toIO.read.IO.read(file_name)is used.IO.read(file_name)withFile.read(file_name).Command Injection. Ruby on Rails Cheat Sheet: Command Injection
PR Type
Bug fix
Description
Replace
IO.readwithFile.readto prevent command injectionFix security vulnerability in file reading operation
Ensure file names starting with
|don't execute shell commandsDiagram Walkthrough
File Walkthrough
main.rb
Security fix for file reading operationrake_tasks/crazy_fun/main.rb
IO.read(file_name)withFile.read(file_name)inparse_filemethod
|